#include "shmem.h"

static struct shm_param para;

struct student
{
    int num;
    char name[64];
};

int main(int argc, char *argv[])
{
    int ret = -1;

    // 注意进程双方共享内存的大小一致
    ret = shm_init(&para, "shm_test", 1024);
    if(ret < 0)
    {
        return -1;
    }

    struct student *addr = (struct student *)shm_getaddr(&para);
    if(addr == NULL)
    {
        return -1;
    }

    printf("num = %d\n", addr->num);
    printf("num = %s\n", addr->name);

    //如果这个内存一直要用，那么不要删除
    shm_del(&para);

    return 0;
}